李守中

Windows 上的虚拟化

Table of Contents

1. HyperV 虚拟化

1.1. 激活 Windows 系列虚拟机

如果用的是 windows server 正版系统,标准版和数据中心版分别可以安装 2 个和无限个正版的虚拟机。

Hyper V 虚拟机的激活需要用到 AVMA 密钥,执行 slmgr /ipk <AVMA_key>

对 Windows Server 2019 使用以下 AVMA 密钥:

  • Datacenter: H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW
  • Standard: TNK62-RXVTB-4P47B-2D623-4GF74
  • Essentials: 2CTP7-NHT64-BP62M-FV6GG-HFV28

对 Windows Server 版本 1909, 1903 和 1809 使用以下 AVMA 密钥:

  • Datacenter: H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW
  • Standard: TNK62-RXVTB-4P47B-2D623-4GF74

对 Windows Server 版本 1803 和 1709 使用以下 AVMA 密钥:

  • Datacenter: TMJ3Y-NTRTM-FJYXT-T22BY-CWG3J
  • Standard: C3RCX-M6NRP-6CXC9-TW2F2-4RHYD

对 Windows Server 2016 使用以下 AVMA 密钥:

  • Datacenter: TMJ3Y-NTRTM-FJYXT-T22BY-CWG3J
  • Standard: C3RCX-M6NRP-6CXC9-TW2F2-4RHYD
  • Essentials: B4YNW-62DX9-W8V6M-82649-MHBKQ

可以针对 Windows Server 2012 R2 使用以下 AVMA 密钥:

  • Datacenter: Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW
  • Standard: DBGBW-NPF86-BJVTX-K3WKJ-MTB6V
  • Essentials: K2XGM-NMBT3-2R6Q8-WF2FK-P36R2

1.2. NIC 和 Hyper V 虚拟交换机的 MAC 地址冲突

开启 NIC 后所有网卡会被汇聚成一个虚拟网卡,一个物理网卡的 MAC 地址会被分配给这个虚拟网卡。

Hyper V 建立虚拟交换机之后,同样地,一个物理网卡的 MAC 地址也会被分配给这个虚拟网卡。

创建 NIC 之后,所有的物理网卡将无法被独立使用,必须通过 NIC 才能进行网络操作。

在 NIC 创建之后,Hyper V 建立的虚拟交换机此时只能将 NIC 虚拟网卡再次虚拟为虚拟交换机。

此时,NIC 的 MAC 地址会被分配给虚拟交换机。MAC 地址冲突出现。

Windows server 事件管理器会出现警告,事件 ID 16945,事件描述为:

MAC conflict: A port on the virtual switch has the same MAC as one of the underlying team members on Team Nic Microsoft Network Adapter Multiplexor Driver.

然后,我查了查,发现,这个问题从 Windows server 2012 R2 就存在了,直到 Windows Server 2019 也没有解决。

给 NIC 网卡手动指定 MAC 地址的方法没有用。只能让 Hyper V 创建的虚拟交换机不使用 NIC 网卡。

2. VMWare Workstation 桌面虚拟化

2.1. 物理机不能复制文件或文本到虚拟机

VMWare Workstation 有个 Copy and Paste Feature 特性,效果是在物理机上 copy 文件或者文本,可以直接 paste 到虚拟机中。

这个特性的配置方式如下:

  • 虚拟机 -> 设置 -> 选项 -> 客户机隔离的两个 check box 都打勾;
  • 如果 Linux 虚拟机不带桌面,安装 open-vm-tools ;虚拟机带桌面,安装 open-vm-tools-desktop

但是这个特性的启用需要满足官方文档给出的条件 ( VMWare workstation 15 ):

  • You must install VMware Tools in a virtual machine to use the copy and paste feature.
  • The copy and paste feature works with Linux and Windows hosts and Linux, Windows, and Solaris 10 guests only.
  • The copy and paste feature requires Linux hosts and guests to run X Windows and Solaris 10 guests to run an Xorg X server and JDS/Gnome.
  • Copying and pasting email attachments is restricted to images or files smaller than 4 MB.
  • Copying and pasting plain text and formatted text (including the formatting) is restricted to amounts less than 4MB.
  • Copying and pasting text is restricted to text in languages that can be represented by Unicode characters.
  • Workstation Pro uses the PNG format to encode images that are copied and pasted. Copying and pasting images is restricted to images smaller than 4 MB after conversion to PNG format.
  • You cannot copy and paste files between virtual machines.

注意 The copy and paste feature requires Linux hosts and guests to run X Windows 这句,跑在软件内的 Linux 虚拟机只有使用 x-windows 作为桌面底层技术才能启用这个特性。

而 Debian 系统从 Debian 10 开始用的 Gnome 桌面的底层是 wayland,所以从 Debian 10 开始使用 Gnome 桌面的虚拟机不能使用这个特性。

Ubuntu 直到 20.04 LTS 使用的 Gnome 桌面的底层还是 x11,所以可以使用这个特性。Debian 10 使用的 xfce 底层也用了 x11。

启用桌面的条件下,在终端执行 echo $XDG_SESSION_TYPE 可以查看目前桌面用的是 wayland 还是 x-windows ( 目前是 x11 )。

2.2. 与 VirtualBox 共存时,使用桥接网络的虚拟机断网

在 VMware Workstation 界面上,点击 编辑 -> 虚拟网络编辑器 (-> 更改设置) -> 选中类型为 桥接模式 的条目 -> 已桥接至 改成实际上连接到网络的网卡即可。



Last Update: 2023-08-16 Wed 10:03

Generated by: Emacs 28.2 (Org mode 9.5.5)   Contact: [email protected]

若正文中无特殊说明,本站内容遵循: 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议